{extend name="public/base" /} {block name="title"}
<title>编辑：{$data.title}</title>
{__block__}
<link href="//cdn.bootcss.com/limonte-sweetalert2/6.6.8/sweetalert2.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/iCheck/1.0.2/skins/all.css" rel="stylesheet">
<style>
    .toolbar {
        border-bottom: solid 1px #eee;
    }

    .textcontent {
        height: 400px;
        border: solid 1px #eee;
    }
</style>
<script>
    var uploadUrl = "{:url('admin/article/upload')}";
    var editArticleUrl = "{:url('admin/article/edit',['id'=>$data['id']])}";
    var indexArticleUrl = "{:url('admin/article/index')}"
</script>{/block} {block name="page-heading"}
<div class="col-sm-4">
    <h2>编辑：{$data.title}</h2>
    <ol class="breadcrumb">
        <li>
            <a href="{:url('admin/index/home')}">主页</a>
        </li>
        <li>
            <a href="{:url('admin/article/index')}">文章管理</a>
        </li>
        <li>
            <strong>文章编辑</strong>
        </li>
    </ol>
</div>
{/block} {block name="content"}
<form class="form-horizontal" role="form" id="editArticleForm">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>文章信息</h5>
            <div class="ibox-tools">
                <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="form-group">
                <label class="col-sm-2 control-label">标题</label>
                <div class="col-sm-10">
                    <input type="text" name="title" class="form-control" placeholder="在此输入文章标题" value="{$data.title}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">栏目</label>
                <div class="col-sm-10">
                    <select class="form-control m-b" name="cid">
                        <option value="">请选择栏目</option>
                        {foreach name="category_list" item="category"}
                        <option value="{$category.id}" {eq name="data.cid" value="$category.id"}selected{/eq}>{$category.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">标签</label>
                <div class="col-sm-10">
                    {foreach name="tag_list" item="tag" key="k"}
                    <label class="checkbox-inline i-checks">
                        <input type="checkbox" value="{$tag.id}"  name="tag" onclick="getArticleTag()" {if condition="in_array($tag_list[$k]['id'],$tids)"}checked{/if}> &nbsp;{$tag.name}
                    </label> {/foreach}
                    <input type="hidden" name="tid" id="tid">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">关键词</label>
                <div class="col-sm-10">
                    <input type="text" name="keywords" class="form-control" placeholder="多个关键词用顿号分隔" value="{$data.keywords}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">文章描述</label>
                <div class="col-sm-10">
                    <input type="text" name="description" class="form-control" placeholder="可不填，自动获取文章300字符" value="{$data.description}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">作者</label>
                <div class="col-sm-10">
                    <input type="text" name="author" class="form-control" placeholder="在此输入作者" value="{$data.author}">
                </div>
            </div>
            <div class=" form-group">
                <label class="col-sm-2 control-label">内容</label>
                <div class="col-sm-10">
                    <div class="editor">
                        <div id="toolbar" class="toolbar">
                        </div>
                        <div id="text" class="textcontent">
                            {$data.content}
                        </div>
                    </div>
                    <textarea id="content" name="content" style="display:none"> {$data.content}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否置顶</label>
                <div class="col-sm-10">
                    <label class="radio-inline i-checks">
                        <input type="radio" value="1" id="is_top1" name="is_top" {eq name="data.is_top" value="1"}checked{/eq}>&nbsp;&nbsp;是
                    </label>
                    <label class="radio-inline i-checks">
                        <input type="radio" value="0" id="is_top0" name="is_top" {eq name="data.is_top" value="0"}checked{/eq}>&nbsp;&nbsp;否
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否原创</label>
                <div class="col-sm-10">
                    <label class="radio-inline i-checks">
                        <input type="radio" value="1" id="is_original1" name="is_original" {eq name="data.is_original" value="1"}checked{/eq}>&nbsp;&nbsp;是
                    </label>
                    <label class="radio-inline i-checks">
                        <input type="radio" value="0" id="is_original0" name="is_original" {eq name="data.is_original" value="0"}checked{/eq}>&nbsp;&nbsp;否
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否发布</label>
                <div class="col-sm-10">
                    <label class="radio-inline i-checks">
                        <input type="radio" value="1" id="status1" name="status" {eq name="data.status" value="1"}checked{/eq}>&nbsp;&nbsp;是
                    </label>
                    <label class="radio-inline i-checks">
                        <input type="radio" value="0" id="status0" name="status" {eq name="data.status" value="0"}checked{/eq}>&nbsp;&nbsp;否
                    </label>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-10 col-sm-offset-2">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </div>
    </div>
</form> {/block} {block name="script"}{__block__}
<script src="//cdn.bootcss.com/limonte-sweetalert2/6.6.8/sweetalert2.min.js"></script>
<script src="//cdn.bootcss.com/iCheck/1.0.2/icheck.min.js"></script>
<script src="//cdn.bootcss.com/jquery-validate/1.17.0/jquery.validate.min.js"></script>
<script src="//cdn.bootcss.com/jquery-validate/1.17.0/localization/messages_zh.min.js"></script>
<script src="https://cdn.bootcss.com/wangEditor/3.0.8/wangEditor.min.js"></script>

<script src="__CUSTOME__/js/admin.validate.js"></script>
<script src="__CUSTOME__/js/admin.common.js"></script>
<script>
    $(function () {
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        });
    });
    var E = window.wangEditor
    var editor = new E('#toolbar', '#text')
    editor.customConfig.uploadImgServer = uploadUrl
    editor.customConfig.uploadImgMaxSize = 3 * 1024 * 1024;
    editor.customConfig.uploadImgMaxLength = 1;
    editor.customConfig.uploadFileName = 'image';
    editor.customConfig.uploadImgHooks = {
        fail: function (xhr, editor, result) {
            swal('自定义提示', result.msg, 'error')
        },
        error: function (xhr, editor) {

        },
        customInsert: function (insertImg, result, editor) {
            var url = result.url
            insertImg(url)
        }
    }
    editor.customConfig.customAlert = function (info) {
        swal('自定义提示', info, 'error')
    }
    editor.customConfig.onchange = function (html) {
        $('#content').val(html);
        // console.log($('#content').val());
    }
    editor.create()
    $('.w-e-toolbar').css('flex-wrap', 'wrap');
</script> {/block}